package com.zxl.always.on.display.configs;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.text.TextUtils;

import com.zxl.always.on.display.ApplicationHelper;
import com.zxl.always.on.display.tools.LogUtils;

/**
 * Created by Administrator on 2016/10/6.
 */

public class ChannelHelper {

    private static final String DATA_CHANNEL = "UMENG_CHANNEL";

    private static String sRealChannel;

    /**
     * 初始化渠道号
     */
    public static void initChannel() {
        try {
            Context context = ApplicationHelper.getContext();
            ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
            sRealChannel = applicationInfo.metaData.getString(DATA_CHANNEL);
        } catch (Exception e) {
            sRealChannel = "200";
            e.printStackTrace();
        }
        LogUtils.d("sChannel : " + sRealChannel + ", ");
    }

    /**
     * 当前版本的渠道号
     *
     * @return
     */
    public static String getChannel() {
        if (TextUtils.isEmpty(sRealChannel)) {
            initChannel();
        }
        return sRealChannel;
    }

    public static boolean isWaps() {
        return ChannelHelper.getChannel().equals("waps");
    }

    public static boolean isXm() {
        return ChannelHelper.getChannel().equals("xiaomi");
    }


}
